#ifndef NODE_H
#define NODE_H

#include<iostream>
#include<vector>



namespace gull{
    namespace core{
        class Node;
		
		typedef  std::vector<Node*> children;
		
        class Node {
        public:
            
            
            Node(const char* name);
            Node(const Node& node);
            ~Node();
            Node& operator=(const Node& node);
            inline const Node* getParent() const;
            inline void setParent(const Node* parent);
            inline const children* getChildren() const;
            inline  Node* getChild(const char* name) const;
            void addChild(Node* child);
            void removeChild(Node* child);
            void removeAllChildren();
			
            inline const char* getName() const;
            
            
        protected:
            
            
        private:
            children m_children;
            const Node* m_parent;
            char* m_name;
        };
        
		
        void Node::setParent(const Node* parent){
            m_parent = parent;
        }
        
        const Node* Node::getParent() const{
            return m_parent;
        }
        
        const children* Node::getChildren() const{
            return &m_children;
        }
        
		Node* Node::getChild(const char* name) const
		{
			int length = m_children.size();
			for (int i = 0; i < length; i++)
			{
				if(!strcmp(name, m_children[i]->getName()))
					return m_children[i];
			}
			
			return NULL;
        }
        
		
        
        const char* Node::getName() const{
            return m_name;
        }        
		
    }
}

extern std::ostream& operator<<(std::ostream& o,const gull::core::Node& n);

#endif